package com.lifq.tmp;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;

/**
 * @Author: LiFuqiang
 * @Date: 2022/10/13 10:43
 * @Version 1.0
 * @description
 */
public class TestT3 {
    public static String value;

    public static void main(String[] args) throws IOException {
//        String dd = "Zmxpbms6CiAgZGVwbG95bWVudDoKICAgIG9wdGlvbjoKICAgICAgdGFyZ2V0OiB5YXJuLXBlci1qb2IKICAgICAgZGV0YWNoZWQ6CiAgICAgIHNodXRkb3duT25BdHRhY2hlZEV4aXQ6CiAgICAgIHpvb2tlZXBlck5hbWVzcGFjZToKICAgICAgam9ibWFuYWdlcjoKICAgIHByb3BlcnR5OiAjQHNlZTogaHR0cHM6Ly9jaS5hcGFjaGUub3JnL3Byb2plY3RzL2ZsaW5rL2ZsaW5rLWRvY3MtcmVsZWFzZS0xLjEyL2RlcGxveW1lbnQvY29uZmlnLmh0bWwKICAgICAgJGludGVybmFsLmFwcGxpY2F0aW9uLm1haW46IGNvbS5zdHJlYW14aHViLnN0cmVhbXguZmxpbmsucXVpY2tzdGFydC5kYXRhc3RyZWFtLlF1aWNrU3RhcnRBcHAKICAgICAgcGlwZWxpbmUubmFtZTogUXVpY2tTdGFydCBBcHAoRmxpbmsgMS4xMykKICAgICAgdGFza21hbmFnZXIubnVtYmVyT2ZUYXNrU2xvdHM6IDEKICAgICAgcGFyYWxsZWxpc20uZGVmYXVsdDogMgogICAgICBqb2JtYW5hZ2VyLm1lbW9yeToKICAgICAgICBmbGluay5zaXplOgogICAgICAgIGhlYXAuc2l6ZToKICAgICAgICBqdm0tbWV0YXNwYWNlLnNpemU6CiAgICAgICAganZtLW92ZXJoZWFkLm1heDoKICAgICAgICBvZmYtaGVhcC5zaXplOgogICAgICAgIHByb2Nlc3Muc2l6ZToKICAgICAgdGFza21hbmFnZXIubWVtb3J5OgogICAgICAgIGZsaW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mFsOgogICAgICBkZWxheToKICAjIHRhYmxlCiAgdGFibGU6CiAgICBwbGFubmVyOiBibGluayAjIChibGlua3xvbGR8YW55KQogICAgbW9kZTogc3RyZWFtaW5nICMoYmF0Y2h8c3RyZWFtaW5nKQoKIyBrYWZrYSBzb3VyY2UKa2Fma2Euc291cmNlOgogIGJvb3RzdHJhcC5zZXJ2ZXJzOiBrZmsxOjkwOTIsa2ZrMjo5MDkyLGtmazM6OTA5MgogIHRvcGljOiB0ZXN0X3VzZXIKICBncm91cC5pZDogdXNlcl8wMQogIGF1dG8ub2Zmc2V0LnJlc2V0OiBlYXJsaWVzdAoKIyBteXNxbApqZGJjOgogIGRyaXZlckNsYXNzTmFtZTogY29tLm15c3FsLmNqLmpkYmMuRHJpdmVyCiAgamRiY1VybDogamRiYzpteXNxbDovL2xvY2FsaG9zdDozMzA2L3Rlc3Q/dXNlU1NMPWZhbHNlJmFsbG93UHVibGljS2V5UmV0cmlldmFsPXRydWUKICB1c2VybmFtZTogcm9vdAogIHBhc3N3b3JkOiAxMjM0NTY=";
//        String str = new String(Base64.getDecoder().decode(dd));
//        System.out.println(str);
        //Long.valueOf(null);
        List<String> ss = new ArrayList<>();
        ss.add("1");
        ss.add("2");
        System.out.println(String.join(",", ss));
    }

    public static List<String> readFile() throws IOException {
        String path = "C:\\Users\\lifq\\办公\\项目\\大数据底座\\初始化脚本-20230607\\init-sql";
        File dir = new File(path);
        List<String> lines = new ArrayList<>();
        File[] files = dir.listFiles();
        for(File file:files){
            lines.addAll(Files.readAllLines(Paths.get(file.getAbsolutePath())));
        }

        return lines;
    }

    public static String extractTable(String line){
        String[] tmp = line.split("\\s+");
        return trimTableName(tmp[2]);
    }

    public static String trimTableName(String name){
        if(!name.startsWith("`")){
            return name;
        }
        int index = name.indexOf("`",1);
        return name.substring(1,index);
    }
}
